#include"process.h"
#include<string.h>
#include<unistd.h>

#define NUM 101
#define STYLE1 '='
#define STYLE2 '>'
#define STYLE3 '.'
#define LENGTH 6

void FlushProcess(double total,double current)
{
    static int cnt=0;
    ++cnt;
    char buffer[NUM];
    char lable[LENGTH];
    memset(buffer,0,sizeof(buffer));
    memset(lable,' ',sizeof(lable));
    
    double rate=(current/total)*100;
    int num=(int)rate;
    int i=0;
    for(i=0;i<num;i++){
        buffer[i]=STYLE1;
    }
    if(num-1<99){
    buffer[num-1]=STYLE2;
    }

    int length=cnt%LENGTH;
    int j=0;
    for(j=0;j<length;j++){
        lable[j]=STYLE3;
    }

    printf("[%-100s][%.1f%%][%-6s]\r",buffer,rate,lable);
    fflush(stdout);

}
